<!-- 防止学生用户未登录就使用 -->
<?php
session_start();
if (!isset($_SESSION["role"])||($_SESSION["role"]!="student"))
    header("location:../index.php");
?>

<!-- 删除学生需要删除的志愿 -->
<?php
  include("../functions/db_conn.php");
  $will=$_GET['will'];


//$stuno='17010001';
$stuno=$_SESSION["username"];
  $sql="DELETE FROM stusoci WHERE StuNo='$stuno' and WillOrder=$will;";
  $res=mysql_query($sql);
// 如果学生还有其他志愿，着志愿号全部-1处理
if($res)
{
    $sql="UPDATE stusoci SET WillOrder=WillOrder-1 WHERE StuNo='$stuno' AND WillOrder>$will;";
    $res=mysql_query($sql);
    // 自动刷新已选社团页
    if($res)

        echo "<script>location.href='showmywill.php';</script>";
    else
        echo "<script>location.href='showmywill.php';</script>";
}

echo "<script>location.href='showmywill.php';</script>";
?>
